<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common-app/taglibs.jsp"%>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="${res_app}/css/wuxi.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript" src="${res}/js/public.js"></script>
<script type="text/javascript" src="${res_app}/js/app/proposal/irisPrpPrepare.js"></script>
<title>科技成果审核</title>
<style type="text/css">
.button_orange { 
	height:25px; font-size:12px; color:#cc3300; border:1px #cc9933 solid; 
	background:url(${res}/images/button_orange.gif); padding:0 15px; *padding:0 10px;
	_padding:0 10px; cursor: pointer;
}
.soBox1 { padding:10px 15px; border: 1px solid #F0CDCC; background:#fffdf4; overflow:hidden; }
.mask {       
            position: absolute; top: 0px; filter: alpha(opacity=60); background-color: #777;     
            z-index: 1002; left: 0px;     
            opacity:0.5; -moz-opacity:0.5;     
        }   
</style>
</head>
<body>
<security:authorize ifAnyGranted="A_AUTH_SCS">
 <%-- <cpt:helpTips key="prpapproveTips4scs" id="prpapproveTips4scs"></cpt:helpTips> --%>
 <div class="clear_h10"></div>
 </security:authorize>
	<input type="hidden" id="childDiv" class="thickbox" />
		<form method="post" id="mainForm">
			<input type="hidden" id="prpCodes" name="prpCodes" value="" />
			<input type="hidden" id="type" name="type" value="" />
		</form>
	<div class="soBox">
		<div class="detail ico_search">
			<table>
				<tr>
					<td rowspan="2"><strong>检索条件：</strong>
					</td>
					<td>
						<cpt:search key="techPayoffs_search"  repeatColumn="3" displayCount="6" leftStyle="width:100px"></cpt:search>
					</td>
				</tr>
				<tr>
				<td>
					<div class="clear_h10"></div>
					<input type='button' id='searchBt' class="button_an" value='查询' />
				</td>
				</tr>
				
			</table>
		</div>
	</div>
	<!-- <div class="soBox1" style="margin-top: 1px;">
			<table>
				<tr>
					<td rowspan="2" style="color: #FF0000">
					温馨提示：科学技术奖励审核不能进行批量审核，只能点击数据列表“操作”列中的“进入审核”链接进入审核页面进行审核操作。
					</td>
				</tr>
			</table>
	</div> -->
	<div class="clear_h10"></div>
	<div>
		<div id='TopBarMnt'></div>
		<table id='dataGrid'></table>
		<div id='dataBar'></div>
	</div>
	<div id="mask" class="mask"></div>    
	<script type="text/javascript">
	var irisGrid = new IrisGrid("dataGrid", "dataBar", 'TopBarMnt');
	var prcWin = new progressWin("${res}");//初始化遮罩层
	
	//兼容火狐、IE8   
    //显示遮罩层    
    function showMask(){     
        $("#mask").css("height",$(document).height());     
        $("#mask").css("width",$(document).width());     
        $("#mask").show();     
    }  
    //隐藏遮罩层  
    function hideMask(){     
          
        $("#mask").hide();     
    }  
    
	var getSelOpt = function() {
		var g = "";
		$("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
			if (obj.checked) {
				g += "," + obj.id.replace("jqg_dataGrid_", "");
			}
		});
		if (g != "") {
			g = g.substring(1);
		}
		return $.trim(g);
	};
	
	function showApproveDialog(type, gridObj, selectIdArray, recordRows){
		var prpCodes= getSelOpt();
		if(recordRows==''){
			prpCodes=selectIdArray+'';
		}
		if(prpCodes==""){
			scmWarn("请选择一条记录");
			return false;
		}
		
		if(type=="approve"){
			
			if(!checkSelect(selectIdArray)){
				return false;
			}
		}
		
		if(type=="approve"){
				
				var prpnum = prpCodes.split(",").length;
				$("#prpCodes").val(prpCodes);
				$("#type").val(type);
				var options = {
						beforeSubmit : function() {
							prcWin.openWin();//打开遮罩层
							$("#approve").attr("disabled",true);
						}, // 表单提交前的回调函数
						success : function(msg) {
							prcWin.closeWin();
							scmSuccess(msg);
							irisGrid.getGridDom().jqGrid("refresh",0);//0是本页1是首页
							$("#approve").attr("disabled",false);
						},// 表单成功提交后的回调函数
						error : function() {
							scmError("操作失败,请联系系统管理员");
							prcWin.closeWin();
							$("#approve").attr("disabled",false);
						},
						url: "${ctx}/prpapprove/"+type
					};
				if(confirm("是否确认此"+prpnum+"份科技成果?")){
					var url="${ctx}/prpapprove/openprpapprovedialog?category=A&prpCodes="+prpCodes+"&type="+type+"&TB_iframe=true&height=250&width=410";
					var title="申报审核意见（最多为500字）";
					showThickBox(url,title);
					//$("#mainForm").ajaxSubmit(options);
				}
				else{
					return;
				}
			
		}else{
			if(prpCodes.split(",").length>1){
				scmError("退回操作限制只能单个退回");
				return false;
			}
			
			var url="${ctx}/prpapprove/openprpapprovedialog?category=A&prpCodes="+prpCodes+"&type="+type+"&TB_iframe=true&height=250&width=410";
			var title="申报审核意见（最多为500字）";
			showThickBox(url,title);	
		}
		
	}
	
	function checkSelect(selectArray){
		var checked = 1;
		$("#approve").removeAttr("disabled");//去除该属性
		var grantcodeStr = "";
		var statYearStr = "";
		for(var i=0;i<selectArray.length;i++){
			var status=irisGrid.getGridDom().jqGrid('getCell',selectArray[i],"13");
			var flagCan=irisGrid.getGridDom().jqGrid('getCell',selectArray[i],"14");
			var grantCode=irisGrid.getGridDom().jqGrid('getCell',selectArray[i],"15");
			var statyear=irisGrid.getGridDom().jqGrid('getCell',selectArray[i],"16");
			if(status=="05"){
				scmWarn("您所选择的这"+selectArray.length+"份科技成果中有部分科技成果已受理，不允许重复确认!");
				checked = 0;
				break;
			}else if(status=='04'&&flagCan=="0") {
				scmWarn("您所选择的这"+selectArray.length+"份科技成果中有部分科技成果的正式PDF未生成，请在生成之后再选择该科技成果进行受理操作");
				checked = 0;
				break;
			}else{
				grantcodeStr += ","+grantCode;
				statYearStr += ","+statyear;
			}
		}
		if(checked==0){
			return false;
		}else if(grantcodeStr!=""){
			return checklimitInfo(grantcodeStr,statYearStr);
		}
		return true;
	}
	
	function closeDialog(){
		tb_remove();
	}

	
		/** 表格初始化**/
		//loadIrisGrid("${res}");
		function buildGrid() {
			
			var columnAttrList = new Array();
			
			columnAttr = new ColumnAttr("成果名称", "zh_title","zh_title", 6, "left", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
			columnAttrList.push(columnAttr);
	        
			columnAttr = new ColumnAttr("成果类型", "grant_name","grant_name", 4, "left", true);
	        columnAttrList.push(columnAttr);
// 			columnAttr = new ColumnAttr("项目类型", "proposal_type_name","proposal_type_name", 3, "center", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
// 			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("成果完成单位", "org_name","org_name", 6, "left", true);//表头，字段名，，，宽度比例，居左，是否需要表头排序
            columnAttrList.push(columnAttr);
			
            columnAttr = new ColumnAttr("归口管理部门", "off_name", "off_name", 7,"center", true);
            columnAttrList.push(columnAttr);
            
			
			columnAttr = new ColumnAttr("财政资金支持", "psn_name","psn_name", 3, "center", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("评价单位", "researcharea_name","researcharea_name", 3, "center", true);
			columnAttrList.push(columnAttr);
			
			/* columnAttr = new ColumnAttr("专题名称", "domain_name","domain_name", 3, "center", true);
			columnAttrList.push(columnAttr); */
			
			
			/* columnAttr = new ColumnAttr("提交时间", "submitDate", "submit_date", 3,"left", true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("水印号", "prp_version","prp_version", 3, "left", true);
			columnAttrList.push(columnAttr); */
			
			
			/* columnAttr = new ColumnAttr("工作进度", "statusName", "status", 5,"center", true);
			columnAttrList.push(columnAttr); */
			
			/* columnAttr = new ColumnAttr("审核意见", "comment", "comment", 3,"center", false);
			columnAttrList.push(columnAttr); */
			
			/* <security:authorize ifAnyGranted="A_AUTH_SCZJ,A_AUTH_SCS">
			columnAttr = new ColumnAttr("项目比对", "fitCompare", "fitCompare", 3,"center", false);
			columnAttrList.push(columnAttr);
			</security:authorize> */
			
			/* columnAttr = new ColumnAttr("PDF", "pdf", "pdf", 5,"center", false);
			columnAttrList.push(columnAttr); */
			
			columnAttr = new ColumnAttr("操作", "", "", 3,"center", false);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("status", "status", "status", 3,"left", false,false,"text",true);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("flagCan", "flagCan", "flagCan", 3,"left", false,false,"text",true);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("grantCode", "grantCode", "grantCode", 3,"left", false,false,"text",true);
			columnAttrList.push(columnAttr);
			columnAttr = new ColumnAttr("statYear", "statYear", "statYear", 3,"left", false,false,"text",true);
			columnAttrList.push(columnAttr);
			
			
			
			columnAttr = new ColumnAttr("posCode", "posCode", "posCode", 3,"left", false,false,"text",true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("grantCode", "grantCode", "grantCode", 3,"left", false,false,"text",true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("subGrantCode", "subGrantCode", "subGrantCode", 3,"left", false,false,"text",true);
			columnAttrList.push(columnAttr);
			
			columnAttr = new ColumnAttr("prpCode", "", "", 3,"left", false,false,"text",true);
			columnAttrList.push(columnAttr);

		
			irisGrid.setColumnAttrs(columnAttrList);
			//打印汇总表功能关闭  
			/* irisGrid.setToolsBar([ 
			   {
				  id : 'report',
				  name : '打印汇总表',
				  trigger : function(gridObj, selectIdArray, recordRows){//按钮onclick方法
						showReportDialog("report", gridObj, selectIdArray, recordRows);
				}
			   }]);
			 */
		   irisGrid.setToolsBar([ 
   			   {
  				  id : 'approve',
  				<security:authorize ifAnyGranted="A_PROPOSAL_AD_SUBMIT">
   				name : '同意上报',
     			</security:authorize>
     			<security:authorize ifAnyGranted="A_AUTH_TJBM,A_AUTH_ZGDW,A_AUTH_ADMIN,A_INFO_INSTITUTE">
       			name : '审核通过',
     			</security:authorize>
  				  
  				  trigger : function(gridObj, selectIdArray, recordRows){//按钮onclick方法
		 					var checkflag = true;
							var prpCodes = getSelOpt();
							prpCodes = prpCodes + "";
							var num = 0;
							var ps = prpCodes.split(",");
							<security:authorize ifAnyGranted="A_AUTH_TJBM">
							checkRecommendLimit("approve", gridObj, selectIdArray, recordRows);
			                </security:authorize>
			                <security:authorize ifAnyGranted="A_PROPOSAL_AD_SUBMIT,A_AUTH_ADMIN,A_INFO_INSTITUTE">
							showApproveDialog2("approve", gridObj, selectIdArray, recordRows);
			                </security:authorize>
   					}
   			   },
   			   {
  				  id : 'turnBack',
  				  name : '退回修改',
  				  trigger : function(gridObj, selectIdArray, recordRows){//按钮onclick方法
  						showApproveDialog2("turnBack", gridObj, selectIdArray, recordRows);
   					}
   			   }
   			<security:authorize ifAnyGranted="A_AUTH_TJBM">
   			   ,
  				{
  				  id : 'notpass',
  				  name : '不同意申报',
  				  trigger : function(gridObj, selectIdArray, recordRows){//按钮onclick方法
  					showApproveDialog2("notpass", gridObj, selectIdArray, recordRows);
   				}
   			   }
   			 ,
             {
               id : 'viewRecommends',
               name : '查看推荐情况 ',
               trigger : viewRecommends
            }
  			   </security:authorize>
   			   ]);
			 
			irisGrid.setUrl("${ctx}/prpapprove/list-tech-payoffs-approve?stat_year=${param.stat_year}");//查询url
			irisGrid.setCaption("暂写");
			irisGrid.setDefaultSortName("status,NLSSORT(zh_title,'NLS_SORT = SCHINESE_PINYIN_M')");//默认排序字段
			irisGrid.setDefaultSortorder("asc");
			irisGrid.setWidth(978);//整个表格宽度
			irisGrid.setCheckAble(true);//表格左边是否要复选框
			irisGrid.setShowRowIndex(true);//是否显示行号
			irisGrid.setQueryBox('searchBt', 'techPayoffs_search');//查询条件 按钮名，查询条件function_key
			irisGrid.setLoadComplete(setGray);
			irisGrid.onSelectAll = function(selectid,isSelect){//全选事件
				checkSelectAll();
			};
			/*
			irisGrid.onSelectRow = function(selectid,isSelect){//审核项目
				//alert(selectid);
				//selectid = encodeURIComponent(selectid);
				//alert(selectid);
				var backFlag = $("#"+selectid+"_backFlag").val();
			   // if(backFlag == 'YES')return;
			
			
				var posCode = $("#posCode_"+selectid).val();
				var grantCode = $("#grantCode_"+selectid).val();
				var subGrantCode = $("#subGrantCode_"+selectid).val();
				var curDate = "${curDate}";
				
				var pcode= $("#prp_Code_"+selectid).val();

	
				//判断该项目是否有退回过
				var backDate = $("#backDate_"+selectid).val();
				var isback = 0;
				if(backDate!=null&&backDate!=''){
					isback = 1;
				}
				var roleId = "${roleId}";
				var off_code = "${off_code}";
				var dialogUrl = "${ctx}/prpapprove/openprpapprovedialog?category=A&off_code="+off_code+"&backFlag="+backFlag+"&roleId="+roleId+"&isback="+isback+"&curDate="+curDate+"&prpCodes="+pcode+"&posCode="+posCode+"&grantCode="+grantCode+"&subGrantCode="+subGrantCode+"&TB_iframe=true&height=250&width=410";
			    window.open(dialogUrl,'newwin');
			};
			*/
			irisGrid.setLoadComplete(setGray);
			irisGrid.onSelectAll = function(selectid, isSelect) {//全选事件
				checkSelectAll();
			}
			irisGrid.onSelectRow = function(selectid, isSelect) {//选择事件
				checkSelectAll2(selectid);
			}
			irisGrid.build();
		}
		
		function viewRecommends() {
			 tb_show("推荐情况表",ctx+'/prpapprove/listOrgRecommends?flag=init&TB_iframe=true&height=520&width=978');
             $(parent.document).find("#TB_ajaxWindowTitle").text("推荐情况表");
		}
		
		function showApproveDialog(pcode){
			var selectid= pcode;
			var curDate = "${curDate}";
			var roleId = "${roleId}";
			var off_code = "${off_code}";
			var posCode = $("#posCode_"+selectid).val();
			
			var grant_type= $("#grant_type_"+selectid).val();
			var grantCode = $("#grantCode_"+selectid).val();
			var subGrantCode = $("#subGrantCode_"+selectid).val();
			var status = $("#status_"+selectid).text();
			var dialogUrl = "${ctx}/prpapprove/openprpapprovedialog?category=A&grant_type="+grant_type+"&off_code="+off_code+"&roleId="+roleId+"&status="+status+"&curDate="+curDate+"&prpCodes="+pcode+"&posCode="+posCode+"&grantCode="+grantCode+"&subGrantCode="+subGrantCode+"&TB_iframe=true&height=250&width=410";
		    window.open(dialogUrl,'newwin');
			
		}
		
		/**
		* 归口部门项限校验
		*/
		function checkRecommendLimit(type, gridObj, selectIdArray, recordRows) {
			var prpCodes = getSelOpt();
            if (recordRows == '') {
                prpCodes = selectIdArray + '';
            }
            if (prpCodes == "") {
                scmWarn("请选择一条记录");
                return false;
            }
		    $.ajax({
		           type: "POST",
		           async:false,
		           url: "${ctx}/prpapprove/approvesConfirm",
		           data: {"prpCodes":prpCodes},
		           beforeSend:function(XMLHttpRequest) {
		        	   showMask();
// 		        	  prcWin.openWin();//打开遮罩层
		           },
		           success: function(msg){
		        	   hideMask();
// 		        	   prcWin.closeWin();
		               var obj = eval("(" + msg + ")");
		               if(obj.isAllNoLimit == "nolimit") { // 如果所有的都没有限制 ，那么直接提交审批
		            	   showApproveDialog2("approve", gridObj, selectIdArray, recordRows);
		            	   return;
		               }
		               
		               if(obj.isAllPass == "pass") {
		                   if(window.confirm(obj.subject)){
	                            showApproveDialog2("approve", gridObj, selectIdArray, recordRows);
		                   } else {
		                       return false;
		                   }
		               } else if(obj.isAllPass == "notpass") {
		                   window.alert(obj.subject);
		               }
		               
		           },// 表单成功提交后的回调函数
		           error : function() {
		               scmError("操作失败,请联系系统管理员");
		               $("input[type='button'][id!='back']").attr("disabled",false);
		               prcWin.closeWin();
		           }
		        });
		}
		
		function showApproveDialog2(type, gridObj, selectIdArray, recordRows) {
			var prpCodes = getSelOpt();
			if (recordRows == '') {
				prpCodes = selectIdArray + '';
			}
			if (prpCodes == "") {
				scmWarn("请选择一条记录");
				return false;
			}
		
			if (type == "approve") {
				
				var prpnum = prpCodes.split(",").length;
				<security:authorize ifAnyGranted="A_PROPOSAL_AD_SUBMIT">
					if (confirm("是否确认同意上报此" + prpnum + "份科技成果?")) {
     			</security:authorize>
     			<security:authorize ifAnyGranted="A_AUTH_TJBM,A_AUTH_ZGDW,A_AUTH_ADMIN,A_INFO_INSTITUTE">
     				if (confirm("是否确认审核通过此" + prpnum + "份科技成果?")) {
     			</security:authorize>
     			
					<security:authorize ifAnyGranted="A_AUTH_TJBM">
						var url = "${ctx}/prpapprove/techPayoffsApproves?prpCodes="+prpCodes+"&status=02"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					</security:authorize>
					
					<security:authorize ifAnyGranted="A_AUTH_ZGDW">
						var url = "${ctx}/prpapprove/techPayoffsApproves?prpCodes="+prpCodes+"&status=03"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					</security:authorize>
					<security:authorize ifAnyGranted="A_AUTH_ADMIN">
						var url = "${ctx}/prpapprove/techPayoffsApproves?prpCodes="+prpCodes+"&status=02"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					</security:authorize>
					<security:authorize ifAnyGranted="A_INFO_INSTITUTE">
						var url = "${ctx}/prpapprove/techPayoffsApproves?prpCodes="+prpCodes+"&status=03"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					</security:authorize>
					
					<security:authorize ifAnyGranted="A_PROPOSAL_AD_SUBMIT">
						var url = "${ctx}/prpapprove/techPayoffsApproves?prpCodes="+prpCodes+"&status=01,95"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					</security:authorize>
					
					tb_show("科技成果审核意见（最多为500字）", url, false);
					
				}
			}else if (type == "turnBack") {
				var prpnum = prpCodes.split(",").length;
				if (confirm("是否确认退回此" + prpnum + "份科技成果?")) {
					<security:authorize ifAnyGranted="A_AUTH_TJBM">
					var url = "${ctx}/prpapprove/techPayoffsApproves?prpCodes="+prpCodes+"&status=02"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					</security:authorize>
					<security:authorize ifAnyGranted="A_AUTH_ZGDW">
						var url = "${ctx}/prpapprove/techPayoffsApproves?prpCodes="+prpCodes+"&status=03"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					</security:authorize>
					<security:authorize ifAnyGranted="A_AUTH_ADMIN">
						var url = "${ctx}/prpapprove/techPayoffsApproves?prpCodes="+prpCodes+"&status=02"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					</security:authorize>
					<security:authorize ifAnyGranted="A_INFO_INSTITUTE">
						var url = "${ctx}/prpapprove/techPayoffsApproves?prpCodes="+prpCodes+"&status=03"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					</security:authorize>
					<security:authorize ifAnyGranted="A_PROPOSAL_AD_SUBMIT">
						var url = "${ctx}/prpapprove/techPayoffsApproves?prpCodes="+prpCodes+"&status=01,95"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
					</security:authorize>
					tb_show("科技成果退回意见（最多为500字）", url, false);
				}
			}

			else if (type == "notpass") {
				var prpnum = prpCodes.split(",").length;
				if (confirm("确定不同意申报吗？如果确定，此" + prpnum + "份科技成果将作废。")) {
					<security:authorize ifAnyGranted="A_AUTH_TJBM">
						var url = "${ctx}/prpapprove/techPayoffsApproves?prpCodes="+prpCodes+"&status=02"+"&operate="+type+"&TB_iframe=true&height=250&width=430";
						tb_show("科技成果退回意见（最多为500字）", url, false);
					</security:authorize>
					}
				}else {
				return;
			}

		}
		
		
		
		function checkSelectAll(){
			$("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
				if($(obj).attr("disabled")){
					$(obj).attr("checked",false);
				}
			});
		}
		
		var getSelOpt = function() {
			var g = "";
			$("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
				if (obj.checked) {
					g += "," + obj.id.replace("jqg_dataGrid_", "");
				}
			});
			if (g != "") {
				g = g.substring(1);
			}
			return $.trim(g);
		};
		
		
		jQuery(function() {
			if("${prpstatus}"!=""){
				try{
				$("#_dyn_criteria2_field").val("prpstatus");
				_dyn_ShowCriteriaTag(document.getElementById("_dyn_criteria2_field"));
				$("#prpstatus").val("${prpstatus}");
				}catch(ee){}
			}
			
			if("${audie_date}"!=""){
				try{
				$("#_dyn_criteria2_field").val("audie_date");
				_dyn_ShowCriteriaTag(document.getElementById("_dyn_criteria2_field"));
				$("#audie_date").val("${audie_date}");
				}catch(ee){}
			}
			
			buildGrid();
		//	if($.browser.msie && $.browser.version<8)
			//	$("#return").addClass("button_orange").css("margin-left","166px");
		//	else
			//	$("#return").addClass("button_orange").css("margin-left","157px");
			
		});
		/** 表格初始化**/
		
		function setGray(){
			var role = '<c:out value="${role}"/>';
			/* $("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
				var id = $(obj).attr("id").replace("jqg_dataGrid_", "");
				var status = $.trim($("#status_"+id).html());
				if(role=='danwei'){
					if(status=="01"){
						$(obj).attr("disabled",false);
						$("#agree_"+id).show();
						$("#refuse_"+id).show();
					}else{
						$(obj).attr("disabled",true);
						$("#agree_"+id).hide();
						$("#refuse_"+id).hide();
					}
				}else if(role=='chushi'){
					if(status=="04" || status=="03"){
						$(obj).attr("disabled",false);
						$("#agree_"+id).show();
						$("#refuse_"+id).show();
					}else if(status=="05"){
						$(obj).attr("disabled",false);
						$("#agree_"+id).show();
						$("#refuse_"+id).show();
					}else{
						$(obj).attr("disabled",true);
						$("#agree_"+id).hide();
						$("#refuse_"+id).hide();
					}
				}
			}); */
		}
		
		function cleanQueryBox(){
			$("[id^='_dyn_criteria'][id$='_c']", "#prpApprove_search4org").each(function(){
				$(this).children().each(function(){
					$(this).val('');
				});
			});
		}
		
		function viewComment(des3Prpcode){
			var url="${ctx}/proposal/view/audit-comment-view?posCode="+des3Prpcode+"&TB_iframe=true&height=390&width=720";
			var title="审核意见";
			showThickBox(url,title);	
		}
		
		/**检查选中项目限项设置**/
		function checklimitInfo(grantcodeStr,statYearStr){
			var checked = 1;
			var msg = "";
			if(grantcodeStr!=""&&'${limitinfo}'!=''){
				grantcodeStr = grantcodeStr.substring(1);
				statYearStr = statYearStr.substring(1);
				var linfoArr = '${limitinfo}'.split(",");
				for(var i=0;i<linfoArr.length;i++){
					var sublinfoArr = linfoArr[i].split("##");//grant_code##grant_name##limit_count##approved_count
					var grantCode1 = sublinfoArr[0];
					var grantName = sublinfoArr[1];
					var limitCount = sublinfoArr[2];
					var approvedCount = sublinfoArr[3];
					var statYear = sublinfoArr[4];
					var grantcodeArr = grantcodeStr.split(",");
					var statYearArr = statYearStr.split(",");
					var selected = 0;
					for(var j=0;j<grantcodeArr.length;j++){
						if(grantcodeArr[j]==grantCode1 && statYearArr[j]==statYear){
							selected++;
						}
					}
					if(selected>0){
					var checkNum = parseInt(approvedCount)+selected;
						if(checkNum>parseInt(limitCount)){
							checked = 0;
							var shen = parseInt(limitCount,10)-parseInt(approvedCount,10);
							if(shen<0){
								shen = 0;
							}
							msg = "您单位申报"+statYear+"年度"+grantName+"类别的项目仅能申报"+limitCount+"项，目前已经上报了"+approvedCount+"项，还能上报"+shen+"项.";
							break;
						}
					}
				}
			}
			if(checked>0){
				return true;
			}
			scmWarn(msg, null, 7000);
			return false;
			
		}

		//审核页面调用该方法刷新页面
		function search(){
			$("#searchBt").click();
		}
		
		
		/**查看单位信息*/
		function orgInfoView(orgCode){
			//$("#orgCode").val(orgCode);
			//$("#mainForm").submit();
			tb_show("查看单位信息","${ctx}/orgmanage/verifyorg/org-info-view?orgCode=" + orgCode
					+ "&TB_iframe=true&height=460&width=950", false);
		}
		
		function showReportDialog(){
			var searchString=jQuery('#dataGrid').jqGrid('getGridParam','postData')['searchString'];
			tb_show("打印汇总表","${ctx}/prpapprove/list-for-report"+"?searchString="+encodeURIComponent(searchString)+"&TB_iframe=true&height=460&width=1024", false);
		}
		
		function viewPrpCheckResults(prpCode){
			tb_show("规则检查结果","${ctx}/prpapprove/prp-check-result?prpCode=" + prpCode
					+ "&TB_iframe=true&height=460&width=824", false);
		}
		
		function showPrpSimilarView(prpCode){
			tb_show("","${ctx}/prpapprove/prp-similar-list?prpCode=" + prpCode +"&TB_iframe=true&height=460&width=820",false);
		}
		/**查看单位信息*/
		function orgResembleView(orgCode,prpCode){
			//$("#orgCode").val(orgCode);
			//$("#mainForm").submit();
			var height = window.screen.height;
            var width = window.screen.width;
			tb_show("查看疑似单位信息","${ctx}/prpapprove/list-resemble-org?orgCode=" + orgCode
					+"&prpCode="+prpCode
					+"&TB_iframe=true&height="+height*0.8+"&width="+width*0.9+"", false);
		
		}
		/** 显示工作进度 */
		function showPrjProgress(keyCode,progressCode){
			var url = ctx + "/prpapprove/showPrjProgress";
			url = url + "?keyCodeStr="+keyCode+"&progressCode="+progressCode;
			url = url + "&TB_iframe=true&height=500&width=700";	
			tb_show("工作进度",url, false);
		}
		function setGray() {
			$("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
				var grant_type = $(this).parents("tr").find("input[name='grantType']").val();
				if (grant_type=="C") {
					$(obj).attr("disabled", "true");
				}
			});
		}
		function checkSelectAll() {
			$("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
				if ($(obj).attr("disabled")) {
					$(obj).attr("checked", false);
				}
			});
		}
		
		function checkSelectAll2(selectId2) {
			$("input:checkbox[id^=jqg_dataGrid_]").each(function(i, obj) {
				var selectId=obj.id.replace("jqg_dataGrid_", "");
				if(selectId==selectId2&&$(obj).attr("disabled")){
					$(obj).attr("checked", false);
				}
			});
		}
	</script>
</body>
</html>